package com.forenow.demo2;

public class Student {
    String name;
    int id;
    double score;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public void paixu(Student[] s){
        for (int i=1;i<s.length;i++) {
            for(int j=0;j<s.length-i;j++){
                if(s[j].getScore()<s[j+1].getScore()){
                    Student x=s[j];
                    s[j]=s[j+1];
                    s[j+1]=x;
                }
            }
        }

    }

    public static void main(String[] args) {
        Student st1 = new Student();
        Student[] array= new Student[3];
        st1.setId(1001);
        st1.setName("jack");
        st1.setScore(98.5);
        Student st2 = new Student();
        st2.setId(1002);
        st2.setName("tomy");
        st2.setScore(99);
        Student st3 = new Student();
        st3.setId(1003);
        st3.setName("tony");
        st3.setScore(97);
        array[0]=st1;
        array[1]=st2;
        array[2]=st3;
        Student s = new Student();
        Student[] s1=array;
        s.paixu(s1);
        for (Student ss : s1) {
            System.out.println(ss.getId()+" "+ss.getName()+" " +ss.getScore()+ "\t");

        }
    }

}
